package com.thoughtworks.turtlemock.expression;

public class Sum implements Expression {
    private final Expression augend;
    private final Expression addend;

    public Sum(Expression augend, Expression addend) {
        this.augend = augend;
        this.addend = addend;
    }

    public Expression plus(Expression expression) {
        return new Sum(this, expression);
    }

    public Expression convert(String to) {
        Expression newAugend = augend.convert(to);
        Expression newAddend = addend.convert(to);
        return new Measurement(((Measurement) newAugend).value + ((Measurement) newAddend).value, to);
    }
}
